<template>
	<view class="content">
		<view class="logo">
			<image src="../../static/222.jpg" style="width: 190rpx;height: 190rpx;" mode=""></image>
		</view>
		<view class="form">
			<view class="form-item">
				<image src="../../static/phone.png" style="width: 27rpx;height: 38rpx;margin-right: 26rpx;" mode="">
				</image>
				<u--input type="number" :maxlength="11" placeholder="请输入手机号码" border="none"
					:placeholderStyle="{'color':'#ABABAB','font-size': '28rpx'}" v-model="form.account"></u--input>
			</view>
			<view class="form-item">
				<image src="../../static/lock.png" style="width: 30rpx;height: 34rpx;margin-right: 26rpx;" mode="">
				</image>
				<u--input type="number" password placeholder="请输入密码" border="none"
					:placeholderStyle="{'color':'#ABABAB','font-size': '28rpx'}" v-model="form.password"></u--input>
			</view>
		</view>
		<view class="login-btn" @click="login()">
			登录
		</view>
		<view class="back-btn" @click="back()">
			<image src="../../static/back.png" style="width: 84rpx;height: 84rpx;margin-bottom: 22rpx;" mode="">
			</image>
			<text>返回</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					account: '',
					password: ''
				}
			}
		},
		methods: {
			// 登录
			login(){
				if (!uni.$u.test.mobile(this.form.account)) {
					this.$u.toast('请输入正确的手机号')
					return
				}
				if (!this.form.password) {
					this.$u.toast('请输入密码')
					return
				}
				uni.$u.http.post('/login/login', this.form).then(res => {
					this.$u.toast('登录成功')
					uni.setStorageSync('token', res.data.token)
					uni.setStorageSync('shop_id', res.data.user.shop_id)
					setTimeout(()=>{
						uni.reLaunch({
							url:'/pages/verifier/verifier'
						})
					},1000)
				})
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		align-items: center;
		flex-direction: column;
	}

	.logo {
		margin-top: 166rpx;
		border-radius: 42rpx;
		overflow: hidden;
	}

	.form {
		margin-top: 88rpx;
		width: 532rpx;

		.form-item {
			margin-top: 38rpx;
			padding-bottom: 18rpx;
			display: flex;
			align-items: center;
			border-bottom: 1rpx solid #E6E6E6;

			.code-btn {
				width: 160rpx;
				height: 38rpx;
				font-size: 24rpx;
				font-weight: 400;
				color: #333333;
				text-align: center;
				line-height: 38rpx;
				background: #ffe300;
				border-radius: 12rpx;
			}
		}

	}

	.login-btn {
		width: 572rpx;
		height: 84rpx;
		background: #D8D8D8 linear-gradient(136deg, #FFECCA 0%, #E7BC70 100%);
		border-radius: 42rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		text-align: center;
		line-height: 84rpx;
		margin-top: 86rpx;
	}

	.back-btn {
		margin-top: 86rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		font-size: 20rpx;
		font-weight: 400;
		color: #333333;
	}
</style>
